#!/bin/bash
doCheck (){
   rs=$?
   if [ $rs -ne 0 ]
   then
        echo "\033[41;37m $1 \033[0m"
        exit
   fi
}

cd ../
sh install.sh
doCheck "打包失败，请检查代码！" 
cd -

host=121.43.193.114
user=root

package="jingcai-task.tar.gz"
echo "\033[41;37m 打包完成，即将开始上传task包并部署... \033[0m"
echo "\033[41;37m 请输入服务器密码: \033[0m"
scp ./target/${package} ${user}@${host}:/root/
doCheck "上传失败！"
echo "\033[41;37m 上传task包完成,下面开始部署 \033[0m"

echo "\033[41;37m 请输入服务器密码: \033[0m"
ssh ${user}@${host} "sh /root/deploy_task.sh"
echo "部署完成"
